import React from 'react'
import { Layout } from 'element-react'
import './life.less'
import { base, lifeUrl } from '../../utils/paths'
import { HashRouter, Link } from 'react-router-dom'
import axios from 'axios'
const useEffect = React.useEffect
const useState = React.useState

function Life() {
  const [list, setlist] = useState([])
  useEffect(() => {
    document.documentElement.scrollTop = 0
    sessionStorage.setItem('msave', 'true')
    axios.get(lifeUrl).then((res) => {
      let data = res.data
      setlist(data.msg)
    })
  }, [])
  return (
    <HashRouter>
      <div id="life">
        <Layout.Row>
          {list.length > 0 ? (
            <div>
              {list.map((item: any) => {
                return (
                  <div className="life_wai">
                    <Link
                      to={{
                        pathname: '/home/des',
                        search: `?id=${item.id}&type=生活日记`,
                      }}
                    >
                      <img src={base + item.pjname} />
                      <div className="life_zz">{item.name}</div>
                    </Link>
                  </div>
                )
              })}
            </div>
          ) : (
            ''
          )}
        </Layout.Row>
      </div>
    </HashRouter>
  )
}
export default Life
